package server;

import java.util.HashMap;
import java.util.Map;

/**
 * web应用封装类
 * @author Lenovo
 *
 */
public class Context {
	
	private String appName;
	
	private Map<String, HttpServlet> servletMap = new HashMap<String, HttpServlet>();
	
	private WebAppClassLoader webAppClassLoader;
	
	private Host host;

	public Context() {
		super();
	}

	public Context(String appName) {
		super();
		this.appName = appName;
	}
	
	public Context(String appName, Host host) {
		super();
		this.appName = appName;
		this.host = host;
		String appBase = host.getAppBase();
		if(!appBase.endsWith("\\")) {
			appBase = appBase + "\\";
		}
		this.webAppClassLoader = new WebAppClassLoader(appBase + appName);
	}

	public String getAppName() {
		return appName;
	}

	public void setAppName(String appName) {
		this.appName = appName;
	}

	public Map<String, HttpServlet> getServletMap() {
		return servletMap;
	}

	public void setServletMap(Map<String, HttpServlet> servletMap) {
		this.servletMap = servletMap;
	}

	public WebAppClassLoader getWebAppClassLoader() {
		return webAppClassLoader;
	}

	public Host getHost() {
		return host;
	}

	@Override
	public String toString() {
		return "Context [appName=" + appName + ", servletMap=" + servletMap + ", webAppClassLoader=" + webAppClassLoader
				+ ", host=" + host + "]";
	}
	
	
}
